<template>
  <div class="trace-qr-infor-container">
    <div class="title-line1">溯源信息</div>
    <div class="main-box">
      <div class="title-line">
        <div class="title-line-left"></div>已扫描次数
        <div class="title-line-right">
          <div></div>
        </div>
      </div>

      <div class="scan-num-box">
        <div class="scan-num-box-left">{{ scanCountLeft }}</div>
        <div class="scan-num-box-right">{{ scanCountRight }}</div>
      </div>
      <productLayout id="productData" :item="traceInfo" :show="show"></productLayout>
      <proprietorLayout id="proprietorData" :item="traceInfo" :show="show"></proprietorLayout>
      <individuationLayout
        id="individuationInfo"
        :item="traceInfo"
        :show="show"
      ></individuationLayout>
      <testReportInfoLayout
        v-if="traceInfo.testReportInfoList&&traceInfo.testReportInfoList.length>0"
        id="testReportInfo"
        :item="traceInfo"
      ></testReportInfoLayout>
      <environmentalDataLayout
        v-if="traceInfo.environmentalDataList&&traceInfo.environmentalDataList.length>0"
        id="environmentalData"
        :item="traceInfo"
      ></environmentalDataLayout>
    </div>
  </div>
</template>

<script>
import productLayout from "./components/product-info-layout/index";
import proprietorLayout from "./components/proprietor-info-layout/index";
import individuationLayout from "./components/individuation-info-layout/index";
import testReportInfoLayout from "./components/test-report-info-layout/index";
import environmentalDataLayout from "./components/environmental-data-info-layout/index";
import traceConfigApi from "@/api/trace-source-web/traceConfig.js";

export default {
  name: "traceability-information",
  components: {
    productLayout,
    proprietorLayout,
    individuationLayout,
    testReportInfoLayout,
    environmentalDataLayout,
  },
  props: {
    traceConfigNo: {
      type: String,
      require: true,
    },
  },
  data() {
    return {
      show: false,
      scanCountLeft: 0,
      scanCountRight: 1,
      traceInfo: {},
    };
  },
  mounted() {
    this.queryTraceInfo();
  },
  methods: {
    queryTraceInfo() {
      traceConfigApi.numberQuery(this.traceConfigNo).then((res) => {
        console.log(res);
        let data = res.data;
        if (res.code === 1) {
          this.show = true;
          this.traceInfo = data;
        } else {
          this.$message.warning(res.msg);
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
@import "~@/styles/variables.scss";
.trace-qr-infor-container {
  display: flex;
  flex-direction: column;
  position: relative;
  max-width: 375px;
  height: 600px;
  overflow: auto;
  padding: 0 10px;
  transition: 0.5s;
  background-color: #fff;
  box-sizing: content-box;
  .title-line1 {
    display: flex;
    justify-content: center;
    position: absolute;
    left: 0;
    top: 0;
    padding-top: 10px;
    font-weight: 500;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-size: 16px;
    color: #222c33;
    padding-top: 30px;
    height: 166px;
    width: 100%;
    background: linear-gradient(180deg, #acd5ff 0%, #63a4f0 100%);
    border-radius: 0px 0px 0px 0px;
  }
  .main-box {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 10px;
    top: 70px;
    width: calc(100% - 20px);
    height: calc(100% - 60px);
    background-color: #fff;
    box-sizing: content-box;
    .title-line {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      padding: 10px 0;
      font-weight: 500;
      font-size: 14px;
      font-family: PingFang SC, PingFang SC;
      color: #0086ff;
      text-align: center;
      font-style: normal;
      text-transform: none;
      box-sizing: content-box;
      .title-line-left {
        flex: 1;
        display: flex;
        align-items: center;
        height: 4px;
        box-sizing: content-box;
        background: url("~@/assets/traceability-qrcode/title-descript.png")
          no-repeat center;
        background-size: contain;
      }
      .title-line-right {
        flex: 1;
        display: flex;
        position: relative;
        z-index: 1;
        justify-content: flex-end;
        align-items: center;
        height: 100%;
        box-sizing: content-box;
        ::before {
          content: "";
          position: absolute;
          left: 0;
          width: 100%;
          height: 4px;
          background: url("~@/assets/traceability-qrcode/title-descript.png")
            no-repeat center;
          background-size: contain;
          transform: rotate(180deg);
        }

        .edit-box {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 49px;
          height: 32px;
          border-radius: 5px 5px 5px 5px;
          border: 1px solid #0480fb;
          cursor: pointer;
          &:hover {
            color: #1f74c7;
            background-color: #c7e3fe;
          }
        }
      }
    }
    .scan-num-box {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 40px;
      font-weight: 500;
      font-size: 34px;
      margin-bottom: 16px;
      font-family: Arial, Arial;
      color: #ffffff;
      text-align: center;
      font-style: normal;
      .scan-num-box-left,
      .scan-num-box-right {
        z-index: 2;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 31px;
        height: 40px;
        background: linear-gradient(180deg, #acd5ff 0%, #63a4f0 100%);
        border-radius: 3px 3px 3px 3px;
        &::before {
          z-index: 1;
          content: "";
          position: absolute;
          left: 0;
          transform: translateY(-50%);
          width: 31px;
          height: 2px;
          background: #ffffff;
        }
      }
      .scan-num-box-left {
        margin-right: 10px;
      }
    }
  }
}
</style>
